package cn.gp.service.impl;

import cn.gp.common.PageInfo;
import cn.gp.entity.Flower;
import cn.gp.mapper.FlowerMapper;
import cn.gp.service.FlowerService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @ClassName FlowerServiceImpl
 * @Description TODO
 * @Author He_Guoping
 * @Date 2023/5/28 17:27
 * @Version 1.0
 */
@Service
public class FlowerServiceImpl implements FlowerService {

    @Autowired
    private FlowerMapper flowerMapper;

    @Override
    public PageInfo<Flower> page(Integer page, Integer pageSize, String name, Integer status, List<Integer> categOne, BigDecimal lowPrice, BigDecimal upperPrice) {
        PageHelper.startPage(page, pageSize);
        Page<Flower> p = (Page<Flower>) flowerMapper.list(name, status, categOne, lowPrice, upperPrice);
        return new PageInfo<>(p.getTotal(), p.getResult());
    }
    @Override
    public boolean save(Flower flower) {
        flowerMapper.save(flower);
        return true;
    }

    @Override
    public boolean update(Flower flower) {
        flowerMapper.update(flower);
        return true;
    }

    @Override
    public boolean deleteById(Integer id) {
        flowerMapper.deleteById(id);
        return true;
    }


}
